#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>

int main()
{
  extern char** environ;
  pid_t id = fork();

  if(id == 0)
  {
    // child
    printf("我是子进程，pid：%d\n", getpid());
    
    //execlp("ls", "ls", "-a", "-l", NULL);
    //execl("/bin/ls", "ls", "-a", "-l", NULL);
    //execlp("lss", "lsss", "-a", NULL);
   
    //char *const myargv[] = {"ls", "-a", "-l", NULL};
    //execv("/bin/ls", myargv);
    //execvp("ls", myargv);
    //execlp("pwd", "pwd", NULL);
    

    //char const* myenv[] = {"MYENV=Good", NULL};
    //putenv("MYENV=Good");
    //execle("./test", NULL, environ);
    exit(1);
  }
  
  int status = 0;
  waitpid(id, &status, 0);
  printf("我是父进程，pid：%d\n", getpid());
  printf("子进程的退出码是：%d\n", WEXITSTATUS(status));

  return 0;
}
